package com.qinglei.recoup.third.controller;

import com.qinglei.recoup.common.domain.CommonRes;
import com.qinglei.recoup.third.event.AlarmInfoEvent;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * 复星测试控制层
 *
 * @author yujunwei
 * @datetime 2022-05-05 15:30
 */
@Api(tags = "复星测试相关操作")
@RequestMapping("/fuxingtest")
@RestController
@Slf4j
public class FuXingTestController {

    @Autowired
    private ApplicationContext applicationContext;

    @ApiOperation(value = "发送报警信息")
    @ApiImplicitParam(name = "eventId", value = "事件ID", paramType = "query", dataType = "long", required = true)
    @PostMapping("/sendAlarmInfo")
    public CommonRes<Object> sendAlarmInfo(@NotNull Long eventId) {
        AlarmInfoEvent alarmInfoEvent = new AlarmInfoEvent(applicationContext);
        alarmInfoEvent.setEventId(eventId);
        applicationContext.publishEvent(alarmInfoEvent);
        return CommonRes.ok("发送报警信息成功");
    }

}
